<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>MySQL数据类型 | Introduction</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../home/part1/3.MySQL建库建表.html" />
    
    
    <link rel="prev" href="../../home/part1/1.MySQL基础操作.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="2.2"
        data-chapter-title="MySQL数据类型"
        data-filepath="home/part1/2.MySQL数据类型.md"
        data-basepath="../.."
        data-revision="Sun Oct 21 2018 16:32:53 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="home/MySQL介绍.html">
            
                
                    <a href="../../home/MySQL介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        MySQL介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="home/part1/MySQL基础.html">
            
                
                    <a href="../../home/part1/MySQL基础.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        Mysql基础
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="home/part1/1.MySQL基础操作.html">
            
                
                    <a href="../../home/part1/1.MySQL基础操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        MySQL基础操作
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="2.2" data-path="home/part1/2.MySQL数据类型.html">
            
                
                    <a href="../../home/part1/2.MySQL数据类型.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        MySQL数据类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="home/part1/3.MySQL建库建表.html">
            
                
                    <a href="../../home/part1/3.MySQL建库建表.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        MySQL建库建表
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="home/part1/4.DML操作：增,删,改.html">
            
                
                    <a href="../../home/part1/4.DML操作：增,删,改.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        DML操作：增,删,改
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="home/part1/5.DQL操作：数据查询.html">
            
                
                    <a href="../../home/part1/5.DQL操作：数据查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        DQL操作：数据查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="home/part1/6.数据导入和导出.html">
            
                
                    <a href="../../home/part1/6.数据导入和导出.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        数据导入和导出
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="home/part2/MySQL高级.html">
            
                
                    <a href="../../home/part2/MySQL高级.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        MySQL高级
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="home/part2/1.MySQL的多表联查.html">
            
                
                    <a href="../../home/part2/1.MySQL的多表联查.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        MySQL的多表联查
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="home/part2/2.MySQL的事务处理.html">
            
                
                    <a href="../../home/part2/2.MySQL的事务处理.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        MySQL的事务处理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="home/part2/3.MySQL的视图及其它.html">
            
                
                    <a href="../../home/part2/3.MySQL的视图及其它.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        MySQL的视图及其它
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="home/part2/4.MySQL的触发器.html">
            
                
                    <a href="../../home/part2/4.MySQL的触发器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        MySQL的触发器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="home/part2/6.MySQL日志及数据恢复.html">
            
                
                    <a href="../../home/part2/6.MySQL日志及数据恢复.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        MySQL日志及数据恢复
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="home/part2/7.慢查询及sql优化.html">
            
                
                    <a href="../../home/part2/7.慢查询及sql优化.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        慢查询及sql优化
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="home/part3/Python连接MySQL.html">
            
                
                    <a href="../../home/part3/Python连接MySQL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        Python连接MySQL
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="home/part3/1.CRUD.html">
            
                
                    <a href="../../home/part3/1.CRUD.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        CRUD
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >Introduction</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="mysql-&#x6570;&#x636E;&#x7C7B;&#x578B;">MySQL &#x6570;&#x636E;&#x7C7B;&#x578B;</h1>
<hr>
<ul>
<li><h3 id="&#x6570;&#x503C;&#x7C7B;&#x578B;">&#x6570;&#x503C;&#x7C7B;&#x578B;</h3>
<pre><code class="lang-sql">  tinyint 1&#x5B57;&#x8282; &#x53EF;&#x4EE5;&#x8868;&#x793A; 0-255 (&#x65E0;&#x7B26;&#x53F7;) &#x53EF;&#x4EE5;&#x8868;&#x793A; -128 ~ 127 (&#x6709;&#x7B26;&#x53F7;)

  int 4&#x5B57;&#x8282; &#x65E0;&#x7B26;&#x53F7;(0&#xFF0C;4 294 967 295) &#x6709;&#x7B26;&#x53F7; (-2 147 483 648&#xFF0C;2 147 483 647)

  &#x200B;decimal &#x4EE5;&#x5B57;&#x7B26;&#x4E32;&#x5F62;&#x5F0F;&#x5B58;&#x50A8;&#x7684;&#x6D6E;&#x70B9;&#x6570; decimal(5, 2) &#x8868;&#x793A;&#x6570;&#x503C;&#x603B;&#x5171;5&#x4F4D;, &#x5C0F;&#x6570;&#x5360;2&#x4F4D;
</code></pre>
</li>
<li><h3 id="&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&#x7C7B;&#x578B;">&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&#x7C7B;&#x578B;</h3>
<pre><code class="lang-sql">  datetime 8&#x5B57;&#x8282; 1000-01-01 00:00:00 <span class="hljs-comment">-- 9999-12-31 23:59:59</span>
</code></pre>
</li>
<li><h3 id="&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;">&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;</h3>
<pre><code class="lang-sql">  char &#x5B9A;&#x957F;&#x5B57;&#x7B26;&#x4E32;&#x200B; char(7) &#x4E0D;&#x7BA1;&#x5B9E;&#x9645;&#x63D2;&#x5165;&#x591A;&#x5C11;&#x5B57;&#x7B26;, &#x5B83;&#x90FD;&#x4F1A;&#x5360;&#x7528;7&#x4E2A;&#x5B57;&#x7B26;&#x4F4D;&#x7F6E;(&#x4E2D;&#x6587;&#x4E00;&#x4E2A;&#x6C49;&#x5B57;&#x4E5F;&#x662F;&#x4E00;&#x4E2A;&#x4F4D;&#x7F6E;)

  varchar &#x53D8;&#x957F;&#x5B57;&#x7B26;&#x4E32; varchar(7) &#x5982;&#x679C;&#x5B9E;&#x9645;&#x63D2;&#x5165;4&#x4E2A;&#x5B57;&#x7B26;, &#x90A3;&#x4E48;&#x5B83;&#x53EA;&#x5360;4&#x4E2A;&#x5B57;&#x7B26;&#x4F4D;&#x7F6E;

  text &#x8FD9;&#x79CD;&#x7C7B;&#x578B;&#x7528;&#x6765;&#x5B58;&#x653E;&#x8D85;&#x5927;&#x6587;&#x672C;

  &#x200B;enum &#x679A;&#x4E3E;&#x7C7B;&#x578B;( &#x591A;&#x9009;&#x4E00; ) &#x200B;sex enum(&apos;w&apos;,&apos;m&apos;,&apos;x&apos;) &#x4EE3;&#x8868;sex&#x8FD9;&#x4E2A;&#x5B57;&#x6BB5;, &#x53EF;&#x4EE5;&#x53D6; &apos;w&apos;, &apos;m&apos;, &apos;x&apos; &#x4E2D;&#x7684;&#x4E00;&#x4E2A;&#x503C;
</code></pre>
</li>
<li><h3 id="&#x8868;&#x7684;&#x5B57;&#x6BB5;&#x7EA6;&#x675F;">&#x8868;&#x7684;&#x5B57;&#x6BB5;&#x7EA6;&#x675F;</h3>
<pre><code class="lang-sql">  unsigned &#x65E0;&#x7B26;&#x53F7;

  &#x200B;int(4) &#x663E;&#x793A;&#x5BBD;&#x5EA6;

  &#x200B;zerofill &#x96F6;&#x586B;&#x5145;, &#x4F4D;&#x6570;&#x4E0D;&#x591F;&#x7684;&#x65F6;&#x5019;&#x7528;&#x524D;&#x5BFC;&#x96F6;&#x586B;&#x5145;

  &#x200B;not null &#x4E0D;&#x80FD;&#x4E3A;&#x7A7A; &#x5728;&#x64CD;&#x4F5C;&#x6570;&#x636E;&#x5E93;&#x65F6;&#x5982;&#x679C;&#x8F93;&#x5165;&#x8BE5;&#x5B57;&#x6BB5;&#x7684;&#x6570;&#x636E;&#x4E3A;NULL &#xFF0C;&#x5C31;&#x4F1A;&#x62A5;&#x9519;

  &#x200B;default &#x8BBE;&#x7F6E;&#x9ED8;&#x8BA4;&#x503C;

  &#x200B;primary key &#x4E3B;&#x952E; &#x4E0D;&#x80FD;&#x4E3A;&#x7A7A; &#x4E14;&#x552F;&#x4E00;

  &#x200B;auto_increment &#x5B9A;&#x4E49;&#x5217;&#x4E3A;&#x81EA;&#x589E;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x4E00;&#x822C;&#x7528;&#x4E8E;&#x4E3B;&#x952E;&#xFF0C;&#x6570;&#x503C;&#x4F1A;&#x81EA;&#x52A8;&#x52A0;1&#x3002;

  &#x200B;unique &#x552F;&#x4E00;
</code></pre>
</li>
<li><h3 id="mysql&#x7684;&#x8FD0;&#x7B97;&#x7B26;">MySQL&#x7684;&#x8FD0;&#x7B97;&#x7B26;</h3>
<pre><code class="lang-sql">  &#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;&#xFF1A;+ - * / %

  &#x6BD4;&#x8F83;&#x8FD0;&#x7B97;&#x7B26;&#xFF1A;= &gt; &lt; &gt;= &lt;= &lt;&gt; !=

  &#x6570;&#x636E;&#x5E93;&#x7279;&#x6709;&#x7684;&#x6BD4;&#x8F83;&#xFF1A;in&#xFF0C;not in, is null,is not null,like, between and

  &#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;&#xFF1A;and or not

  like: &#x652F;&#x6301;&#x7279;&#x6B8A;&#x7B26;&#x53F7;%&#x548C;_ ; &#x5176;&#x4E2D; %&#x8868;&#x793A;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x4EFB;&#x610F;&#x5B57;&#x7B26;&#xFF0C;_&#x8868;&#x793A;&#x4EFB;&#x610F;&#x4E00;&#x4F4D;&#x5B57;&#x7B26;&#x3002;
</code></pre>
</li>
<li><h3 id="&#x6570;&#x503C;&#x7C7B;&#x578B;">&#x6570;&#x503C;&#x7C7B;&#x578B;</h3>
<pre><code class="lang-sql">  MySQL&#x652F;&#x6301;&#x6240;&#x6709;&#x6807;&#x51C6;SQL&#x6570;&#x503C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x3002;

  &#x8FD9;&#x4E9B;&#x7C7B;&#x578B;&#x5305;&#x62EC;&#x4E25;&#x683C;&#x6570;&#x503C;&#x6570;&#x636E;&#x7C7B;&#x578B;(INTEGER&#x3001;SMALLINT&#x3001;DECIMAL&#x548C;NUMERIC)&#xFF0C;&#x4EE5;&#x53CA;&#x8FD1;&#x4F3C;&#x6570;&#x503C;&#x6570;&#x636E;&#x7C7B;&#x578B;(FLOAT&#x3001;REAL&#x548C;DOUBLE PRECISION)&#x3002;

  &#x5173;&#x952E;&#x5B57;INT&#x662F;INTEGER&#x7684;&#x540C;&#x4E49;&#x8BCD;&#xFF0C;&#x5173;&#x952E;&#x5B57;DEC&#x662F;DECIMAL&#x7684;&#x540C;&#x4E49;&#x8BCD;&#x3002;

  BIT&#x6570;&#x636E;&#x7C7B;&#x578B;&#x4FDD;&#x5B58;&#x4F4D;&#x5B57;&#x6BB5;&#x503C;&#xFF0C;&#x5E76;&#x4E14;&#x652F;&#x6301;MyISAM&#x3001;MEMORY&#x3001;InnoDB&#x548C;BDB&#x8868;&#x3002;

  &#x4F5C;&#x4E3A;SQL&#x6807;&#x51C6;&#x7684;&#x6269;&#x5C55;&#xFF0C;MySQL&#x4E5F;&#x652F;&#x6301;&#x6574;&#x6570;&#x7C7B;&#x578B;TINYINT&#x3001;MEDIUMINT&#x548C;BIGINT&#x3002;&#x4E0B;&#x9762;&#x7684;&#x8868;&#x663E;&#x793A;&#x4E86;&#x9700;&#x8981;&#x7684;&#x6BCF;&#x4E2A;&#x6574;&#x6570;&#x7C7B;&#x578B;&#x7684;&#x5B58;&#x50A8;&#x548C;&#x8303;&#x56F4;&#x3002;
</code></pre>
</li>
</ul>
<table>
<thead>
<tr>
<th>&#x7C7B;&#x578B;</th>
<th>&#x5927;&#x5C0F;</th>
<th>&#x8303;&#x56F4;&#xFF08;&#x6709;&#x7B26;&#x53F7;&#xFF09;</th>
<th>&#x8303;&#x56F4;&#xFF08;&#x65E0;&#x7B26;&#x53F7;&#xFF09;</th>
<th>&#x7528;&#x9014;</th>
</tr>
</thead>
<tbody>
<tr>
<td>TINYINT</td>
<td>1 &#x5B57;&#x8282;</td>
<td>(-128&#xFF0C;127)</td>
<td>(0&#xFF0C;255)</td>
<td>&#x5C0F;&#x6574;&#x6570;&#x503C;</td>
</tr>
<tr>
<td>SMALLINT</td>
<td>2 &#x5B57;&#x8282;</td>
<td>(-32 768&#xFF0C;32 767)</td>
<td>(0&#xFF0C;65 535)</td>
<td>&#x5927;&#x6574;&#x6570;&#x503C;</td>
</tr>
<tr>
<td>MEDIUMINT</td>
<td>3 &#x5B57;&#x8282;</td>
<td>(-8 388 608&#xFF0C;8 388 607)</td>
<td>(0&#xFF0C;16 777 215)</td>
<td>&#x5927;&#x6574;&#x6570;&#x503C;</td>
</tr>
<tr>
<td>INT&#x6216;INTEGER</td>
<td>4 &#x5B57;&#x8282;</td>
<td>(-2 147 483 648&#xFF0C;2 147 483 647)</td>
<td>(0&#xFF0C;4 294 967 295)</td>
<td>&#x5927;&#x6574;&#x6570;&#x503C;</td>
</tr>
<tr>
<td>BIGINT</td>
<td>8 &#x5B57;&#x8282;</td>
<td>(-9 233 372 036 854 775 808&#xFF0C;9 223 372 036 854 775 807)</td>
<td>(0&#xFF0C;18 446 744 073 709 551 615)</td>
<td>&#x6781;&#x5927;&#x6574;&#x6570;&#x503C;</td>
</tr>
<tr>
<td>FLOAT</td>
<td>4 &#x5B57;&#x8282;</td>
<td>(-3.402 823 466 E+38&#xFF0C;-1.175 494 351 E-38)&#xFF0C;0&#xFF0C;(1.175 494 351 E-38&#xFF0C;3.402 823 466 351 E+38)</td>
<td>0&#xFF0C;(1.175 494 351 E-38&#xFF0C;3.402 823 466 E+38)</td>
<td>&#x5355;&#x7CBE;&#x5EA6; &#x6D6E;&#x70B9;&#x6570;&#x503C;</td>
</tr>
<tr>
<td>DOUBLE</td>
<td>8 &#x5B57;&#x8282;</td>
<td>(-1.797 693 134 862 315 7 E+308&#xFF0C;-2.225 073 858 507 201 4 E-308)&#xFF0C;0&#xFF0C;(2.225 073 858 507 201 4 E-308&#xFF0C;1.797 693 134 862 315 7 E+308)</td>
<td>0&#xFF0C;(2.225 073 858 507 201 4 E-308&#xFF0C;1.797 693 134 862 315 7 E+308)</td>
<td>&#x53CC;&#x7CBE;&#x5EA6; &#x6D6E;&#x70B9;&#x6570;&#x503C;</td>
</tr>
<tr>
<td>DECIMAL</td>
<td>&#x5BF9;DECIMAL(M,D) &#xFF0C;&#x5982;&#x679C;M&gt;D&#xFF0C;&#x4E3A;M+2&#x5426;&#x5219;&#x4E3A;D+2</td>
<td>&#x4F9D;&#x8D56;&#x4E8E;M&#x548C;D&#x7684;&#x503C;</td>
<td>&#x4F9D;&#x8D56;&#x4E8E;M&#x548C;D&#x7684;&#x503C;</td>
<td>&#x5C0F;&#x6570;&#x503C;</td>
</tr>
</tbody>
</table>
<ul>
<li><h3 id="&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&#x7C7B;&#x578B;">&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&#x7C7B;&#x578B;</h3>
<pre><code class="lang-sql">  &#x8868;&#x793A;&#x65F6;&#x95F4;&#x503C;&#x7684;&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&#x7C7B;&#x578B;&#x4E3A;DATETIME&#x3001;DATE&#x3001;TIMESTAMP&#x3001;TIME&#x548C;YEAR&#x3002;

  &#x6BCF;&#x4E2A;&#x65F6;&#x95F4;&#x7C7B;&#x578B;&#x6709;&#x4E00;&#x4E2A;&#x6709;&#x6548;&#x503C;&#x8303;&#x56F4;&#x548C;&#x4E00;&#x4E2A;&quot;&#x96F6;&quot;&#x503C;&#xFF0C;&#x5F53;&#x6307;&#x5B9A;&#x4E0D;&#x5408;&#x6CD5;&#x7684;MySQL&#x4E0D;&#x80FD;&#x8868;&#x793A;&#x7684;&#x503C;&#x65F6;&#x4F7F;&#x7528;&quot;&#x96F6;&quot;&#x503C;&#x3002;

  TIMESTAMP&#x7C7B;&#x578B;&#x6709;&#x4E13;&#x6709;&#x7684;&#x81EA;&#x52A8;&#x66F4;&#x65B0;&#x7279;&#x6027;&#xFF0C;&#x5C06;&#x5728;&#x540E;&#x9762;&#x63CF;&#x8FF0;&#x3002;
</code></pre>
</li>
</ul>
<table>
<thead>
<tr>
<th>&#x7C7B;&#x578B;</th>
<th>&#x5927;&#x5C0F;(&#x5B57;&#x8282;)</th>
<th>&#x8303;&#x56F4;</th>
<th>&#x683C;&#x5F0F;</th>
<th>&#x7528;&#x9014;</th>
</tr>
</thead>
<tbody>
<tr>
<td>DATA</td>
<td>3</td>
<td>1000-01-01/9999-12-31</td>
<td>YYYY-MM-DD</td>
<td>&#x65E5;&#x671F;&#x503C;</td>
</tr>
<tr>
<td>TIME</td>
<td>3</td>
<td>&apos;-838:59:59&apos;/&apos;838:59:59&apos;</td>
<td>HH:MM:SS</td>
<td>&#x65F6;&#x95F4;&#x503C;&#x6216;&#x6301;&#x7EED;&#x65F6;&#x95F4;</td>
</tr>
<tr>
<td>YEAR</td>
<td>1</td>
<td>1901/2155</td>
<td>YYYY</td>
<td>&#x5E74;&#x4EFD;&#x503C;</td>
</tr>
<tr>
<td>DATETIME</td>
<td>8</td>
<td>1000-01-01 00:00:00/9999-12-31 23:59:59</td>
<td>YYYY-MM-DD HH:MM:SS</td>
<td>&#x6DF7;&#x5408;&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&#x503C;</td>
</tr>
<tr>
<td>TIMESTAMP</td>
<td>4</td>
<td>1970-01-01 00:00:00/2037 &#x5E74;&#x67D0;&#x65F6;</td>
<td>YYYYMMDD HHMMSS</td>
<td>&#x6DF7;&#x5408;&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&#x503C;&#xFF0C;&#x65F6;&#x95F4;&#x6233;</td>
</tr>
</tbody>
</table>
<ul>
<li><h3 id="&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;">&#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;</h3>
<pre><code class="lang-sql">  &#x5B57;&#x7B26;&#x4E32;&#x7C7B;&#x578B;&#x6307;CHAR&#x3001;VARCHAR&#x3001;BINARY&#x3001;VARBINARY&#x3001;BLOB&#x3001;TEXT&#x3001;ENUM&#x548C;<span class="hljs-operator"><span class="hljs-keyword">SET</span>&#x3002;&#x8BE5;&#x8282;&#x63CF;&#x8FF0;&#x4E86;&#x8FD9;&#x4E9B;&#x7C7B;&#x578B;&#x5982;&#x4F55;&#x5DE5;&#x4F5C;&#x4EE5;&#x53CA;&#x5982;&#x4F55;&#x5728;&#x67E5;&#x8BE2;&#x4E2D;&#x4F7F;&#x7528;&#x8FD9;&#x4E9B;&#x7C7B;&#x578B;&#x3002;
</span></code></pre>
</li>
</ul>
<table>
<thead>
<tr>
<th>&#x7C7B;&#x578B;</th>
<th>&#x5927;&#x5C0F;</th>
<th>&#x7528;&#x9014;</th>
</tr>
</thead>
<tbody>
<tr>
<td>CHAR</td>
<td>0-255&#x5B57;&#x8282;</td>
<td>&#x5B9A;&#x957F;&#x5B57;&#x7B26;&#x4E32;</td>
</tr>
<tr>
<td>VARCHAR</td>
<td>0-65535 &#x5B57;&#x8282;</td>
<td>&#x53D8;&#x957F;&#x5B57;&#x7B26;&#x4E32;</td>
</tr>
<tr>
<td>TINYBLOB</td>
<td>0-255&#x5B57;&#x8282;</td>
<td>&#x4E0D;&#x8D85;&#x8FC7; 255 &#x4E2A;&#x5B57;&#x7B26;&#x7684;&#x4E8C;&#x8FDB;&#x5236;&#x5B57;&#x7B26;&#x4E32;</td>
</tr>
<tr>
<td>TINYTEXT</td>
<td>0-255&#x5B57;&#x8282;</td>
<td>&#x77ED;&#x6587;&#x672C;&#x5B57;&#x7B26;&#x4E32;</td>
</tr>
<tr>
<td>BLOB</td>
<td>0-65 535&#x5B57;&#x8282;</td>
<td>&#x4E8C;&#x8FDB;&#x5236;&#x5F62;&#x5F0F;&#x7684;&#x957F;&#x6587;&#x672C;&#x6570;&#x636E;</td>
</tr>
<tr>
<td>TEXT</td>
<td>0-65 535&#x5B57;&#x8282;</td>
<td>&#x957F;&#x6587;&#x672C;&#x6570;&#x636E;</td>
</tr>
<tr>
<td>MEDIUMBLOB</td>
<td>0-16 777 215&#x5B57;&#x8282;</td>
<td>&#x4E8C;&#x8FDB;&#x5236;&#x5F62;&#x5F0F;&#x7684;&#x4E2D;&#x7B49;&#x957F;&#x5EA6;&#x6587;&#x672C;&#x6570;&#x636E;</td>
</tr>
<tr>
<td>MEDIUMTEXT</td>
<td>0-16 777 215&#x5B57;&#x8282;</td>
<td>&#x4E2D;&#x7B49;&#x957F;&#x5EA6;&#x6587;&#x672C;&#x6570;&#x636E;</td>
</tr>
<tr>
<td>LONGBLOB</td>
<td>0-4 294 967 295&#x5B57;&#x8282;</td>
<td>&#x4E8C;&#x8FDB;&#x5236;&#x5F62;&#x5F0F;&#x7684;&#x6781;&#x5927;&#x6587;&#x672C;&#x6570;&#x636E;</td>
</tr>
<tr>
<td>LONGTEXT</td>
<td>0-4 294 967 295&#x5B57;&#x8282;</td>
<td>&#x6781;&#x5927;&#x6587;&#x672C;&#x6570;&#x636E;</td>
</tr>
</tbody>
</table>
<pre><code>```sql
CHAR&#x548C;VARCHAR&#x7C7B;&#x578B;&#x7C7B;&#x4F3C;&#xFF0C;&#x4F46;&#x5B83;&#x4EEC;&#x4FDD;&#x5B58;&#x548C;&#x68C0;&#x7D22;&#x7684;&#x65B9;&#x5F0F;&#x4E0D;&#x540C;&#x3002;&#x5B83;&#x4EEC;&#x7684;&#x6700;&#x5927;&#x957F;&#x5EA6;&#x548C;&#x662F;&#x5426;&#x5C3E;&#x90E8;&#x7A7A;&#x683C;&#x88AB;&#x4FDD;&#x7559;&#x7B49;&#x65B9;&#x9762;&#x4E5F;&#x4E0D;&#x540C;&#x3002;&#x5728;&#x5B58;&#x50A8;&#x6216;&#x68C0;&#x7D22;&#x8FC7;&#x7A0B;&#x4E2D;&#x4E0D;&#x8FDB;&#x884C;&#x5927;&#x5C0F;&#x5199;&#x8F6C;&#x6362;&#x3002;

BINARY&#x548C;VARBINARY&#x7C7B;&#x7C7B;&#x4F3C;&#x4E8E;CHAR&#x548C;VARCHAR&#xFF0C;&#x4E0D;&#x540C;&#x7684;&#x662F;&#x5B83;&#x4EEC;&#x5305;&#x542B;&#x4E8C;&#x8FDB;&#x5236;&#x5B57;&#x7B26;&#x4E32;&#x800C;&#x4E0D;&#x8981;&#x975E;&#x4E8C;&#x8FDB;&#x5236;&#x5B57;&#x7B26;&#x4E32;&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x5B83;&#x4EEC;&#x5305;&#x542B;&#x5B57;&#x8282;&#x5B57;&#x7B26;&#x4E32;&#x800C;&#x4E0D;&#x662F;&#x5B57;&#x7B26;&#x5B57;&#x7B26;&#x4E32;&#x3002;&#x8FD9;&#x8BF4;&#x660E;&#x5B83;&#x4EEC;&#x6CA1;&#x6709;&#x5B57;&#x7B26;&#x96C6;&#xFF0C;&#x5E76;&#x4E14;&#x6392;&#x5E8F;&#x548C;&#x6BD4;&#x8F83;&#x57FA;&#x4E8E;&#x5217;&#x503C;&#x5B57;&#x8282;&#x7684;&#x6570;&#x503C;&#x503C;&#x3002;

BLOB&#x662F;&#x4E00;&#x4E2A;&#x4E8C;&#x8FDB;&#x5236;&#x5927;&#x5BF9;&#x8C61;&#xFF0C;&#x53EF;&#x4EE5;&#x5BB9;&#x7EB3;&#x53EF;&#x53D8;&#x6570;&#x91CF;&#x7684;&#x6570;&#x636E;&#x3002;&#x6709;4&#x79CD;BLOB&#x7C7B;&#x578B;&#xFF1A;TINYBLOB&#x3001;BLOB&#x3001;MEDIUMBLOB&#x548C;LONGBLOB&#x3002;&#x5B83;&#x4EEC;&#x53EA;&#x662F;&#x53EF;&#x5BB9;&#x7EB3;&#x503C;&#x7684;&#x6700;&#x5927;&#x957F;&#x5EA6;&#x4E0D;&#x540C;&#x3002;

&#x6709;4&#x79CD;TEXT&#x7C7B;&#x578B;&#xFF1A;TINYTEXT&#x3001;TEXT&#x3001;MEDIUMTEXT&#x548C;LONGTEXT&#x3002;&#x8FD9;&#x4E9B;&#x5BF9;&#x5E94;4&#x79CD;BLOB&#x7C7B;&#x578B;&#xFF0C;&#x6709;&#x76F8;&#x540C;&#x7684;&#x6700;&#x5927;&#x957F;&#x5EA6;&#x548C;&#x5B58;&#x50A8;&#x9700;&#x6C42;&#x3002;
```
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../home/part1/1.MySQL基础操作.html" class="navigation navigation-prev " aria-label="Previous page: MySQL基础操作"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../home/part1/3.MySQL建库建表.html" class="navigation navigation-next " aria-label="Next page: MySQL建库建表"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
